﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EIA.SLClient.PlatManage.PMMgr" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
	xmlns:EIA_SLClient_Utility="clr-namespace:EIA.SLClient.Utility;assembly=EIA.SLClient.Utility" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	x:Class="EIA.SLClient.PlatManage.PMMgr.DicItemListView"
	mc:Ignorable="d"
	d:DesignWidth="400" d:DesignHeight="480">
	<UserControl.Resources>
		<local:DicItemListViewModel x:Key="DicItemListViewModelDataSource" />
		<DataTemplate x:Key="OptDataTemplate">
			<StackPanel d:DesignWidth="100" Orientation="Horizontal">
				<HyperlinkButton Content="编辑" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" BorderThickness="0">
					<EIA_SLClient_Utility:BindingHelper.AncestorBinding>
						<EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.UpdateItemCommand" AncestorTypeName="DataGrid"/>
					</EIA_SLClient_Utility:BindingHelper.AncestorBinding>
				</HyperlinkButton>
				<HyperlinkButton Content="删除" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0">
					<EIA_SLClient_Utility:BindingHelper.AncestorBinding>
						<EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.DeleteItemCommand" AncestorTypeName="DataGrid"/>
					</EIA_SLClient_Utility:BindingHelper.AncestorBinding>
				</HyperlinkButton>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="DicItemDataTemplate">
			<Grid d:DesignWidth="120" >
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="0.3*"/>
					<ColumnDefinition Width="0.7*"/>
				</Grid.ColumnDefinitions>
				<Rectangle Fill="#0C000000"/>
				<TextBlock Margin="8,2" TextWrapping="Wrap" Text="{Binding DicIid}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
				<TextBlock TextWrapping="Wrap" Text="{Binding DicIname}" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment" Margin="8,0"/>
			</Grid>
		</DataTemplate>
		<Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
			<Setter Property="Padding" Value="0"/>
			<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			<Setter Property="VerticalContentAlignment" Value="Top"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="TabNavigation" Value="Local"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Grid Background="{TemplateBinding Background}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver">
										<Storyboard>
											<DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor"/>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected"/>
									<VisualState x:Name="Selected">
										<Storyboard>
											<DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor2"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused"/>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Rectangle x:Name="fillColor" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
							<Rectangle x:Name="fillColor2" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
							<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<UserControl.FontSize>
		<StaticResource ResourceKey="FontSize"/>
	</UserControl.FontSize>
	<UserControl.FontFamily>
		<StaticResource ResourceKey="FontFamily"/>
	</UserControl.FontFamily>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource DicItemListViewModelDataSource}}">
		<Grid Margin="4" Background="#FFF2F2F2">
			<Grid.Effect>
				<DropShadowEffect BlurRadius="1" ShadowDepth="1" Opacity="0.1"/>
			</Grid.Effect>
			<Grid.RowDefinitions>
				<RowDefinition Height="32"/>
				<RowDefinition/>
				<RowDefinition Height="32"/>
			</Grid.RowDefinitions>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1">
				<Border.Background>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFFCFCFC" Offset="0"/>
						<GradientStop Color="#FFEBEBEB" Offset="1"/>
					</LinearGradientBrush>
				</Border.Background>
				<Grid>
					<HyperlinkButton Content="添加" Command="{Binding InsertItemCommand}" HorizontalAlignment="Left" Margin="8,0,0,0" VerticalAlignment="Center" />
					<HyperlinkButton Content="重新载入" Command="{Binding RetrieveItemsCommand}" HorizontalAlignment="Right" Margin="0,0,8,0" VerticalAlignment="Center" />
				</Grid>
			</Border>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1,0" Grid.Row="1">
				<Grid>
					<sdk:DataGrid ItemsSource="{Binding DicItemCollection}">
						<sdk:DataGrid.Columns>
							<sdk:DataGridTextColumn Header="键" MinWidth="80" Binding="{Binding DicIid}" CanUserSort="True" />
							<sdk:DataGridTextColumn Header="值" MinWidth="180" Binding="{Binding DicIname}" CanUserSort="True" />
							<sdk:DataGridTemplateColumn Header="操作" CellTemplate="{StaticResource OptDataTemplate}"/>
						</sdk:DataGrid.Columns>
					</sdk:DataGrid>
				</Grid>
			</Border>
			<Border BorderBrush="#FFE1E1E1" BorderThickness="1" Grid.Row="2" Background="WhiteSmoke">
				<Grid/>
			</Border>
		</Grid>
	</Grid>
</UserControl>
